
if __name__ == '__main__':
    fi = open('data301.txt', 'r',encoding="utf-8")
    f = open('result301.txt', 'w',encoding="utf-8")
    cnumd = {}
    name = ''
    count = 0
    flag = 1
    for line in fi:
        if '"name":' in line:
            name = line.split('"')[-2]
            flag = 1
            count +=1
        elif '"value":' in line and flag == 1:
            dx = line.split(':')[-1].strip()
            cnumd[name] = dx
            flag = 0
    for d in cnumd.items():
        f.write("{}:{}\n".format(d[0],d[1]))

    print("一共有{}个地区".format(count))
    f.close()
    fi.close()